// pages/login/login.js
Page({
  data: {
    codeContext: "获取验证码",
    currentTime: 10,
    phone: ""
  },
  getCode(){
    let that = this
    let currentTime = this.data.currentTime
    let codeContext = this.data.codeContext
    let phone = this.data.phone
    if (phone != "" && phone.length == 11) {
      if (codeContext == "获取验证码") {
        let time = setInterval(()=>{
          if (currentTime > 0) {
            currentTime--
            that.setData({
              codeContext: "重新发送("+currentTime+"s)"
            })
          }else{
            clearInterval(time)
            that.setData({
              codeContext:"获取验证码"
            })
          }
        },1000)
      }
    }else{
      wx.showToast({
        title: '手机号码错误',
        icon: "none",
        duration: 2000
      })
    }
  },
  inputPhone(e){
    console.log(e)
    this.setData({
      phone:e.detail.value
    })
  },
  toLogin(){
    wx.setStorage({
      key:"userInfo",
      data:{
        bg: "https://sns-video-hw.xhscdn.com/stream/110/259/01e54227b1aa9068010377038b8a6c688b_259.mp4",
      headerUrl: "/images/sucai/头像.webp",
      username: "trok",
      code: "10086",
      IP_address: "",
      detail: "18岁男大学生",
      sex: 0,
      taglist: ["美食品鉴师","人体描边大师"],
      }
    })
    wx.switchTab({
      url: '/pages/my/my',
    })
  }
})